import 'package:flutter/material.dart';
import 'h_colors.dart';

/// Miaoyi UI框架文本样式系统
///
/// 定义了与Miaoyi框架一致的文本样式，包括标题、正文、强调等不同类型的文本
class HTextStyles {
  /// 构造函数
  ///
  /// 需要[colors]参数来确定文本颜色
  const HTextStyles({
    required this.colors,
  });

  /// 主题颜色
  final HColors colors;

  /// 标题1样式 - 30px, 细体
  TextStyle get h1 => TextStyle(
        fontSize: 30.0,
        fontWeight: FontWeight.w100,
        color: colors.text,
        height: 1.2,
      );

  /// 标题2样式 - 24px, 细体
  TextStyle get h2 => TextStyle(
        fontSize: 24.0,
        fontWeight: FontWeight.w100,
        color: colors.text,
        height: 1.2,
      );

  /// 标题3样式 - 16px, 半粗体
  TextStyle get h3 => TextStyle(
        fontSize: 16.0,
        fontWeight: FontWeight.w600,
        color: colors.text,
        height: 1.2,
      );

  /// 标题4样式 - 14px, 半粗体
  TextStyle get h4 => TextStyle(
        fontSize: 14.0,
        fontWeight: FontWeight.w600,
        color: colors.text,
        height: 1.2,
      );

  /// 标题5样式 - 12px, 半粗体
  TextStyle get h5 => TextStyle(
        fontSize: 12.0,
        fontWeight: FontWeight.w600,
        color: colors.text,
        height: 1.2,
      );

  /// 标题6样式 - 10px
  TextStyle get h6 => TextStyle(
        fontSize: 10.0,
        fontWeight: FontWeight.w100,
        color: colors.text,
        height: 1.2,
      );

  /// 正文文本样式
  TextStyle get body => TextStyle(
        fontSize: 14.0,
        fontWeight: FontWeight.normal,
        color: colors.text,
        height: 1.5,
      );

  /// 小号正文文本样式
  TextStyle get bodySmall => TextStyle(
        fontSize: 12.0,
        fontWeight: FontWeight.normal,
        color: colors.text,
        height: 1.5,
      );

  /// 次要文本样式 - 用于辅助信息
  TextStyle get secondary => TextStyle(
        fontSize: 14.0,
        fontWeight: FontWeight.normal,
        color: colors.textSecondary,
        height: 1.5,
      );

  /// 禁用状态文本样式
  TextStyle get disabled => TextStyle(
        fontSize: 14.0,
        fontWeight: FontWeight.normal,
        color: colors.textDisabled,
        height: 1.5,
      );

  /// 强调文本样式
  TextStyle get emphasis => TextStyle(
        fontSize: 14.0,
        fontWeight: FontWeight.w600,
        color: colors.text,
        height: 1.5,
      );

  /// 链接文本样式
  TextStyle get link => TextStyle(
        fontSize: 14.0,
        fontWeight: FontWeight.normal,
        color: colors.primary,
        height: 1.5,
        decoration: TextDecoration.none,
      );

  /// 激活状态链接文本样式
  TextStyle get linkActive => TextStyle(
        fontSize: 14.0,
        fontWeight: FontWeight.normal,
        color: colors.primaryDark,
        height: 1.5,
        decoration: TextDecoration.underline,
      );

  /// 导航项文本样式
  TextStyle get navItem => TextStyle(
        fontSize: 14.0,
        fontWeight: FontWeight.w600,
        color: const Color(0xFFA7B1C2), // 导航项默认颜色
        height: 1.5,
      );

  /// 激活状态导航项文本样式
  TextStyle get navItemActive => const TextStyle(
        fontSize: 14.0,
        fontWeight: FontWeight.w600,
        color: Colors.white, // 激活状态导航项颜色
        height: 1.5,
      );

  /// 按钮文本样式
  TextStyle buttonText(String type, {bool outline = false, bool disabled = false}) {
    if (disabled) {
      return TextStyle(
        fontSize: 14.0,
        fontWeight: FontWeight.normal,
        color: outline ? colors.textDisabled : Colors.white,
      );
    }

    if (outline) {
      return TextStyle(
        fontSize: 14.0,
        fontWeight: FontWeight.normal,
        color: colors.getButtonColor(type),
      );
    }

    // 根据按钮类型决定文本颜色
    switch (type) {
      case 'default':
      case 'white':
        return TextStyle(
          fontSize: 14.0,
          fontWeight: FontWeight.normal,
          color: colors.text,
        );
      case 'link':
        return TextStyle(
          fontSize: 14.0,
          fontWeight: FontWeight.normal,
          color: colors.primary,
        );
      default:
        return const TextStyle(
          fontSize: 14.0,
          fontWeight: FontWeight.normal,
          color: Colors.white,
        );
    }
  }

  /// 表单标签文本样式
  TextStyle get formLabel => TextStyle(
        fontSize: 14.0,
        fontWeight: FontWeight.normal,
        color: colors.text,
        height: 1.5,
      );

  /// 表单输入文本样式
  TextStyle get formInput => TextStyle(
        fontSize: 14.0,
        fontWeight: FontWeight.normal,
        color: colors.text,
        height: 1.5,
      );

  /// 表单错误文本样式
  TextStyle get formError => TextStyle(
        fontSize: 12.0,
        fontWeight: FontWeight.normal,
        color: colors.danger,
        height: 1.5,
      );

  /// 表单帮助文本样式
  TextStyle get formHelp => TextStyle(
        fontSize: 12.0,
        fontWeight: FontWeight.normal,
        color: colors.textSecondary,
        height: 1.5,
      );

  /// 卡片标题文本样式
  TextStyle get cardTitle => TextStyle(
        fontSize: 16.0,
        fontWeight: FontWeight.w600,
        color: colors.text,
        height: 1.5,
      );

  /// 卡片内容文本样式
  TextStyle get cardContent => TextStyle(
        fontSize: 14.0,
        fontWeight: FontWeight.normal,
        color: colors.text,
        height: 1.5,
      );

  /// 根据按钮尺寸获取文本样式
  TextStyle buttonTextWithSize(String size, String type, {bool outline = false, bool disabled = false}) {
    // 基础样式
    final TextStyle baseStyle = buttonText(type, outline: outline, disabled: disabled);
    
    // 根据尺寸调整字体大小
    switch (size) {
      case 'large':
        return baseStyle.copyWith(fontSize: 16.0);
      case 'small':
        return baseStyle.copyWith(fontSize: 12.0);
      case 'mini':
        return baseStyle.copyWith(fontSize: 11.0);
      case 'normal':
      default:
        return baseStyle;
    }
  }

  /// 输入框文本样式 - 正常尺寸
  TextStyle get input => TextStyle(
        fontSize: 14.0,
        fontWeight: FontWeight.normal,
        color: colors.text,
        height: 1.5,
      );
  
  /// 输入框文本样式 - 大号
  TextStyle get inputLarge => TextStyle(
        fontSize: 16.0,
        fontWeight: FontWeight.normal,
        color: colors.text,
        height: 1.5,
      );
  
  /// 输入框文本样式 - 小号
  TextStyle get inputSmall => TextStyle(
        fontSize: 12.0,
        fontWeight: FontWeight.normal,
        color: colors.text,
        height: 1.5,
      );
  
  /// 输入框文本样式 - 迷你
  TextStyle get inputMini => TextStyle(
        fontSize: 10.0,
        fontWeight: FontWeight.normal,
        color: colors.text,
        height: 1.5,
      );
  
  /// 输入框提示文本样式
  TextStyle get inputHint => TextStyle(
        fontSize: 14.0,
        fontWeight: FontWeight.normal,
        color: colors.textSecondary,
        height: 1.5,
      );
  
  /// 输入框标签文本样式
  TextStyle get inputLabel => TextStyle(
        fontSize: 14.0,
        fontWeight: FontWeight.normal,
        color: colors.textSecondary,
        height: 1.5,
      );
  
  /// 输入框错误文本样式
  TextStyle get inputError => TextStyle(
        fontSize: 12.0,
        fontWeight: FontWeight.normal,
        color: colors.danger,
        height: 1.5,
      );
} 